/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/2/21
 * Time: 21:01
 * Description:
 */
class OuterClass {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    //实例内部类
   public class InnerClass {
        public int data1 = 1000;
        public int data4 = 4;
        private int data5 = 5;
        public static final int data6 = 6;//常量
        public void test() {
            System.out.println(OuterClass.this.data1);
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(this.data4);
            System.out.println(this.data5);
            System.out.println(data6);
            System.out.println("InnerClass的test()方法");
        }
    }

    public void test2() {
        OuterClass.InnerClass innerClass2 = new OuterClass().new InnerClass();
        System.out.println(innerClass2.data1);
        System.out.println("OuterClass的test()方法");
    }

}

public class TestDemo3 {

    public static void main2(String[] args) {
        OuterClass outerClass = new OuterClass();
        outerClass.test2();
    }
    public static void main1(String[] args) {
        //InnerClass innerClass = new InnerClass();
        OuterClass outerClass = new OuterClass();


        //System.out.println(outerClass.data1);
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.test();
        System.out.println(innerClass.data4);

        OuterClass.InnerClass innerClass2 = new OuterClass().new InnerClass();
        innerClass2.test();
    }
}
